﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.Xml;
using Autodesk.Revit.DB;
using YArchitech.Controls;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;
using YJKArch.Utils;
using HYCoordinate;
using HYTools.PublicPreViewer;
using SetPipe.DataDefine;
using SetPipe.Properties;
using SetPipe.Utiltiy;

namespace SetPipe.Forms
{
	public partial class SetPipeInfoForm : System.Windows.Forms.Form
	{
		public bool HasChange
		{
			get
			{
				return this.bChange;
			}
			set
			{
				this.bChange = value;
			}
		}

		public bool isExist
		{
			get
			{
				return this.bExist;
			}
		}

		public SetPipeInfoForm()
		{
			this.bExist = false;
			base.Icon = Resource.YArchitechIcon;
			this.InitializeComponent();
			this.InitComboBox();
			this.InitDic();
			this.GetTypeXmlValue();
			this.ResetOldData();
			this.bChange = false;
			this.bExist = true;
			this.m_MainPreviewer = new Previewer(this.equipmentOccupiedPage, this.pnlPreview.Left, this.pnlPreview.Top, this.pnlPreview.Width, this.pnlPreview.Height, 1u);
			this.pnlPreview.Visible = false;
			base.MouseWheel += this.m_MainPreviewer.MouseWheel;
		}

		private void WriteFileData()
		{
			foreach (object obj in this.FindXmlData().ChildNodes)
			{
				XmlNode xmlNode = (XmlNode)obj;
				if (xmlNode.Name == "PipeOccupied" && xmlNode is XmlElement)
				{
					using (Dictionary<string, List<string>>.Enumerator enumerator2 = this.dicComboBoxText.GetEnumerator())
					{
						while (enumerator2.MoveNext())
						{
							KeyValuePair<string, List<string>> keyValuePair = enumerator2.Current;
							for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
							{
								XmlElement xmlElement = xmlNode.ChildNodes[i] as XmlElement;
								if (xmlElement.Name == keyValuePair.Key)
								{
									xmlElement.SetAttribute("value", this.BuildString(keyValuePair.Value));
								}
							}
						}
						continue;
					}
				}
				if (xmlNode.Name == "EquipmentOccupied" && xmlNode is XmlElement)
				{
					foreach (KeyValuePair<string, List<string>> keyValuePair2 in this.dicComboBoxText)
					{
						for (int j = 0; j < xmlNode.ChildNodes.Count; j++)
						{
							XmlElement xmlElement2 = xmlNode.ChildNodes[j] as XmlElement;
							if (xmlElement2.Name == keyValuePair2.Key)
							{
								xmlElement2.SetAttribute("value", this.BuildString(keyValuePair2.Value));
							}
						}
					}
				}
			}
			this.xmlDoc.Save(this.tempPath);
		}

		[DllImport("user32.dll", EntryPoint = "SendMessageA")]
		public static extern int SendMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);

		private void SetPipeInfoForm_MouseLeave(object sender, EventArgs e)
		{
			this.pictureBox1.Focus();
			if (!base.ClientRectangle.Contains(base.PointToClient(Cursor.Position)))
			{
				int wMsg = 7;
				SetPipeInfoForm.SendMessage(CmdSetPipe._hWndRevit.Handle, wMsg, IntPtr.Zero, IntPtr.Zero);
			}
			else
			{
				base.Focus();
			}
			this.InitDicValue();
			if (this.m_bDataIsChange)
			{
				this.PressEsc();
			}
		}

		private string BuildString(List<string> lststr)
		{
			string text = null;
			foreach (string str in lststr)
			{
				text = text + str + ",";
			}
			return text;
		}

		private void InitDic()
		{
			List<string> value = new List<string>();
			this.dicComboBoxText.Add("comboBox3", value);
			List<string> value2 = new List<string>();
			this.dicComboBoxText.Add("comboBox4", value2);
			List<string> value3 = new List<string>();
			this.dicComboBoxText.Add("comboBox5", value3);
			List<string> value4 = new List<string>();
			this.dicComboBoxText.Add("LengthcomboBox", value4);
			List<string> value5 = new List<string>();
			this.dicComboBoxText.Add("WidthcomboBox", value5);
			List<string> value6 = new List<string>();
			this.dicComboBoxText.Add("HeightcomboBox", value6);
		}

		private void InitDicValue()
		{
			foreach (KeyValuePair<string, List<string>> keyValuePair in this.dicComboBoxText)
			{
				if (keyValuePair.Key == "comboBox3")
				{
					if (!keyValuePair.Value.Contains(this.comboBox3.Text))
					{
						if (keyValuePair.Value.Count >= 10)
						{
							keyValuePair.Value.Remove(keyValuePair.Value.First<string>());
						}
						keyValuePair.Value.Add(this.comboBox3.Text);
					}
				}
				else if (keyValuePair.Key == "comboBox4")
				{
					if (!keyValuePair.Value.Contains(this.comboBox4.Text))
					{
						if (keyValuePair.Value.Count >= 10)
						{
							keyValuePair.Value.Remove(keyValuePair.Value.First<string>());
						}
						keyValuePair.Value.Add(this.comboBox4.Text);
					}
				}
				else if (keyValuePair.Key == "comboBox5")
				{
					if (!keyValuePair.Value.Contains(this.comboBox5.Text))
					{
						if (keyValuePair.Value.Count >= 10)
						{
							keyValuePair.Value.Remove(keyValuePair.Value.First<string>());
						}
						keyValuePair.Value.Add(this.comboBox5.Text);
					}
				}
				else if (keyValuePair.Key == "LengthcomboBox")
				{
					if (!keyValuePair.Value.Contains(this.LengthcomboBox.Text))
					{
						if (keyValuePair.Value.Count >= 10)
						{
							keyValuePair.Value.Remove(keyValuePair.Value.First<string>());
						}
						keyValuePair.Value.Add(this.LengthcomboBox.Text);
					}
				}
				else if (keyValuePair.Key == "WidthcomboBox")
				{
					if (!keyValuePair.Value.Contains(this.WidthcomboBox.Text))
					{
						if (keyValuePair.Value.Count >= 10)
						{
							keyValuePair.Value.Remove(keyValuePair.Value.First<string>());
						}
						keyValuePair.Value.Add(this.WidthcomboBox.Text);
					}
				}
				else if (keyValuePair.Key == "HeightcomboBox" && !keyValuePair.Value.Contains(this.HeightcomboBox.Text))
				{
					if (keyValuePair.Value.Count >= 10)
					{
						keyValuePair.Value.Remove(keyValuePair.Value.First<string>());
					}
					keyValuePair.Value.Add(this.HeightcomboBox.Text);
				}
			}
		}

		private void InitComboBox()
		{
			this.comboBox1.Items.Add(TypeFileInfo.strWaterSupOrDra);
			this.comboBox1.Items.Add(TypeFileInfo.strHvac);
			this.comboBox1.Items.Add(TypeFileInfo.strElectrical);
			this.comboBox1.Items.Add(TypeFileInfo.strElectromechanical);
			this.comboBox1.Items.Add(TypeFileInfo.strOther);
			this.comboBox1.SelectedIndex = 0;
			this.comboBox2.Items.Add(TypeFileInfo.LeftPos);
			this.comboBox2.Items.Add(TypeFileInfo.CorePos);
			this.comboBox2.Items.Add(TypeFileInfo.RightPos);
			this.comboBox2.SelectedIndex = 1;
			this.TypeCombobox.Items.Add(TypeFileInfo.strWaterSupOrDra);
			this.TypeCombobox.Items.Add(TypeFileInfo.strHvac);
			this.TypeCombobox.Items.Add(TypeFileInfo.strElectrical);
			this.TypeCombobox.Items.Add(TypeFileInfo.strElectromechanical);
			this.TypeCombobox.Items.Add(TypeFileInfo.strOther);
			this.TypeCombobox.SelectedIndex = 0;
		}

		public string OccupiedType
		{
			get
			{
				return this.comboBox1.Text;
			}
			set
			{
				this.comboBox1.Text = value;
			}
		}

		public string AlignPosition
		{
			get
			{
				return this.comboBox2.Text;
			}
			set
			{
				this.comboBox2.Text = value;
			}
		}

		public double PipeWidth
		{
			get
			{
				return double.Parse(this.comboBox3.Text) / CommonUnit.MM2Feet;
			}
			set
			{
				this.comboBox3.Text = value.ToString();
			}
		}

		public double PipeHight
		{
			get
			{
				return double.Parse(this.comboBox4.Text) / CommonUnit.MM2Feet;
			}
			set
			{
				this.comboBox4.Text = value.ToString();
			}
		}

		public double DistanceFloor
		{
			get
			{
				return double.Parse(this.comboBox5.Text) / CommonUnit.MM2Feet;
			}
			set
			{
				this.comboBox5.Text = value.ToString();
			}
		}

		public double dLenght
		{
			get
			{
				if (this.LengthcomboBox.Text == "")
				{
					return double.Parse("0") / CommonUnit.MM2Feet;
				}
				return double.Parse(this.LengthcomboBox.Text) / CommonUnit.MM2Feet;
			}
			set
			{
				this.LengthcomboBox.Text = value.ToString();
			}
		}

		public double dWidth
		{
			get
			{
				if (this.WidthcomboBox.Text == "")
				{
					return double.Parse("0") / CommonUnit.MM2Feet;
				}
				return double.Parse(this.WidthcomboBox.Text) / CommonUnit.MM2Feet;
			}
			set
			{
				this.WidthcomboBox.Text = value.ToString();
			}
		}

		public double dHeight
		{
			get
			{
				if (this.HeightcomboBox.Text == "")
				{
					return double.Parse("0") / CommonUnit.MM2Feet;
				}
				return double.Parse(this.HeightcomboBox.Text) / CommonUnit.MM2Feet;
			}
			set
			{
				this.HeightcomboBox.Text = value.ToString();
			}
		}

		public bool IfBackGroundEsc
		{
			get
			{
				bool bifBackGroundEsc = this.m_bifBackGroundEsc;
				this.m_bifBackGroundEsc = false;
				return bifBackGroundEsc;
			}
			private set
			{
				this.m_bifBackGroundEsc = value;
			}
		}

		public bool BIsEndPipeOccupied
		{
			get
			{
				return this.m_bIsEndPipeOccupied;
			}
			set
			{
				this.m_bIsEndPipeOccupied = value;
			}
		}

		[DllImport("user32.dll")]
		public static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);

		private void SetPipeInfoForm_FormClosed(object sender, FormClosingEventArgs e)
		{
			this.bExist = false;
			this.WriteFileData();
			int bVk = 27;
			int dwFlags = 0;
			int dwFlags2 = 2;
			int wMsg = 7;
			SetPipeInfoForm.SendMessage(CmdSetPipe._hWndRevit.Handle, wMsg, IntPtr.Zero, IntPtr.Zero);
			SetPipeInfoForm.keybd_event((byte)bVk, 0, dwFlags, 0);
			SetPipeInfoForm.keybd_event((byte)bVk, 0, dwFlags2, 0);
		}

		public void PressEsc()
		{
			this.IfBackGroundEsc = true;
			int bVk = 27;
			int dwFlags = 0;
			int dwFlags2 = 2;
			int wMsg = 7;
			SetPipeInfoForm.SendMessage(CmdSetPipe._hWndRevit.Handle, wMsg, IntPtr.Zero, IntPtr.Zero);
			SetPipeInfoForm.keybd_event((byte)bVk, 0, dwFlags, 0);
			SetPipeInfoForm.keybd_event((byte)bVk, 0, dwFlags2, 0);
		}

		public Dictionary<int, double> GetParametersByName()
		{
			Dictionary<int, double> result;
			try
			{
				Dictionary<int, double> dictionary = new Dictionary<int, double>();
				dictionary.Add(0, 0.0);
				dictionary.Add(1, 0.0);
				dictionary.Add(2, 0.0);
				dictionary.Add(3, 0.0);
				dictionary[0] = this.MMStringToFeet(this.comboBox3.Text);
				dictionary[1] = this.MMStringToFeet(this.comboBox4.Text);
				dictionary[2] = this.MMStringToFeet(this.comboBox5.Text);
				if (this.comboBox2.Text == "左侧")
				{
					dictionary[3] = 1.0;
				}
				else if (this.comboBox2.Text == "中心")
				{
					dictionary[3] = 2.0;
				}
				else if (this.comboBox2.Text == "右侧")
				{
					dictionary[3] = 3.0;
				}
				result = dictionary;
			}
			catch (Exception)
			{
				throw new CornerMakerException(StaticRescource.StrError_WrongParameter);
			}
			return result;
		}

		public int GetCornerKind()
		{
			string text = this.comboBox2.Text;
			if (text.Equals("左侧"))
			{
				return 1;
			}
			if (text.Equals("中心"))
			{
				return 2;
			}
			if (text.Equals("右侧"))
			{
				return 3;
			}
			return 0;
		}

		public int GetFamilyFileIndex()
		{
			return this.nowFamilyFileIndex;
		}

		private void makeNowFamilyFileIndex()
		{
			if (this.comboBox1.Text == "给排水")
			{
				this.nowFamilyFileIndex = 0;
				return;
			}
			if (this.comboBox1.Text == "暖通")
			{
				this.nowFamilyFileIndex = 1;
				return;
			}
			if (this.comboBox1.Text == "电气")
			{
				this.nowFamilyFileIndex = 2;
				return;
			}
			if (this.comboBox1.Text == "机电")
			{
				this.nowFamilyFileIndex = 3;
				return;
			}
			if (this.comboBox1.Text == "其他")
			{
				this.nowFamilyFileIndex = 4;
			}
		}

		private void MakeNowFamilySymbolIndex()
		{
			if (this.TypeCombobox.Text == "给排水")
			{
				this.EquipmentFamilyIndex = 0;
				return;
			}
			if (this.TypeCombobox.Text == "暖通")
			{
				this.EquipmentFamilyIndex = 1;
				return;
			}
			if (this.TypeCombobox.Text == "电气")
			{
				this.EquipmentFamilyIndex = 2;
				return;
			}
			if (this.TypeCombobox.Text == "机电")
			{
				this.EquipmentFamilyIndex = 3;
				return;
			}
			if (this.TypeCombobox.Text == "其他")
			{
				this.EquipmentFamilyIndex = 4;
			}
		}

		private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
		{
			this.makeNowFamilyFileIndex();
		}

		private void TypeCombobox_SelectedIndexChanged(object sender, EventArgs e)
		{
			this.MakeNowFamilySymbolIndex();
		}

		private double MMStringToFeet(string input)
		{
			return SetPipe.Utiltiy.Utiltiy.FeetMMChange(double.Parse(input), false);
		}

		private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
		{
			if (TypeFileInfo.LeftPos == this.AlignPosition)
			{
				this.pictureBox1.Image = SetPipe.Properties.Resources.左侧;
			}
			else if (TypeFileInfo.CorePos == this.AlignPosition)
			{
				this.pictureBox1.Image = SetPipe.Properties.Resources.中心;
			}
			else if (TypeFileInfo.RightPos == this.AlignPosition)
			{
				this.pictureBox1.Image = SetPipe.Properties.Resources.右侧;
			}
			if (this.bExist)
			{
				this.bChange = true;
			}
		}

		private void ResetOldData()
		{
			this.m_OldData.dWidth = this.comboBox3.Text;
			this.m_OldData.dHeight = this.comboBox4.Text;
			this.m_OldData.dDistanceFloor = this.comboBox5.Text;
		}

		private void button1_Click(object sender, EventArgs e)
		{
			this.bExist = false;
			base.Close();
		}

		private List<CurveInfo> GetPreviewCurveInfo()
		{
			new List<CurveInfo>();
			if (this.arLandPoints.Count == 0)
			{
				this.arLandPoints.Add(new XYZ(2.0, 4.0, 0.0));
				this.arLandPoints.Add(new XYZ(2.0, 2.0, 0.0));
				this.arLandPoints.Add(new XYZ(5.0, 2.0, 0.0));
				this.arLandPoints.Add(new XYZ(5.0, 4.0, 0.0));
			}
			this.lstInsertPt.Clear();
			this.lstInsertPt.AddRange(this.arLandPoints);
			XYZ areaCurveCenterPt = this.GetAreaCurveCenterPt(this.arLandPoints);
			this.lstInsertPt.Add(areaCurveCenterPt);
			XYZ xyz = this.lstInsertPt[this.index];
			this.CalulateTransform(false, false, 0.0, this.dWidth, this.dLenght, xyz);
			this.m_TransVector = Geometry.TransformPoint(xyz, this.m_Transform);
			List<CurveInfo> list = this.CreateLandEdgeloop(this.arLandPoints);
			list.AddRange(this.DrawBasePoint(xyz, 20.0));
			return list;
		}

		protected List<CurveInfo> DrawBasePoint(XYZ ptBase, double lengthBase = 20.0)
		{
			int num = 2;
			List<CurveInfo> list = new List<CurveInfo>();
			double num2 = Common.MMToFeet(lengthBase);
			XYZ ptS = new XYZ(ptBase.X - num2, ptBase.Y + num2, 0.0);
			XYZ ptE = new XYZ(ptBase.X + num2, ptBase.Y - num2, 0.0);
			list.Add(this.NewLine(PenColor.PC_Red, DashStyle.Solid, (float)num, ptS, ptE));
			ptS = new XYZ(ptBase.X - num2, ptBase.Y - num2, 0.0);
			ptE = new XYZ(ptBase.X + num2, ptBase.Y + num2, 0.0);
			list.Add(this.NewLine(PenColor.PC_Red, DashStyle.Solid, (float)num, ptS, ptE));
			return list;
		}

		public XYZ GetAreaCurveCenterPt(List<XYZ> lstPoints)
		{
			XYZ xyz = new XYZ();
			foreach (XYZ xyz2 in lstPoints)
			{
				xyz += xyz2;
			}
			xyz = new XYZ(xyz.X / (double)lstPoints.Count, xyz.Y / (double)lstPoints.Count, xyz.Z / (double)lstPoints.Count);
			return xyz;
		}

		private void CalulateTransform(bool lrMirror, bool tbMirror, double rotateAngle, double bundingBoxWidth, double bundingBoxHeight, XYZ ptOrigin)
		{
			Transform identity = Transform.Identity;
			Transform identity2 = Transform.Identity;
			Transform identity3 = Transform.Identity;
			this.m_Transform = identity.Multiply(identity2);
			this.m_Transform = this.m_Transform.Multiply(identity3);
		}

		private List<CurveInfo> CreateLandEdgeloop(List<XYZ> arPoints)
		{
			List<CurveInfo> list = new List<CurveInfo>();
			if (arPoints.Count > 2)
			{
				for (int i = 0; i < arPoints.Count - 1; i++)
				{
					CurveInfo item = this.NewLine(PenColor.PC_Black, DashStyle.Solid, 2f, arPoints[i], arPoints[i + 1]);
					if (item.CurveObj != null)
					{
						list.Add(item);
					}
				}
				int num = arPoints.Count - 1;
				CurveInfo item2 = this.NewLine(PenColor.PC_Black, DashStyle.Solid, 2f, arPoints[num], arPoints[0]);
				if (item2.CurveObj != null)
				{
					list.Add(item2);
				}
			}
			return list;
		}

		private CurveInfo NewLine(PenColor color, DashStyle dashStyle, float m_LineWidth1, XYZ ptS, XYZ ptE)
		{
			Transform identity = Transform.Identity;
			Transform identity2 = Transform.Identity;
			Transform identity3 = Transform.Identity;
			this.m_Transform = identity.Multiply(identity2);
			this.m_Transform = this.m_Transform.Multiply(identity3);
			XYZ xyz = Geometry.TransformPoint(ptS, this.m_Transform);
			XYZ xyz2 = Geometry.TransformPoint(ptE, this.m_Transform);
			Line curve = null;
			CurveInfo result;
			try
			{
				curve = Line.CreateBound(xyz, xyz2);
				result = new CurveInfo(curve, color, dashStyle, m_LineWidth1);
			}
			catch (Exception)
			{
				result = new CurveInfo(curve, color, dashStyle, m_LineWidth1);
			}
			return result;
		}

		protected override void DefWndProc(ref Message m)
		{
			int msg = m.Msg;
			if (msg == 1125)
			{
				if (m.WParam.ToInt32() != 1)
				{
					return;
				}
				List<TextNoteInfo> textNotes = new List<TextNoteInfo>();
				try
				{
					this.curveInfoList = this.GetPreviewCurveInfo();
					this.m_MainPreviewer.Curves = this.curveInfoList;
					this.m_MainPreviewer.TextNotes = textNotes;
					return;
				}
				catch (Exception)
				{
					return;
				}
			}
			base.DefWndProc(ref m);
		}

		private void btnChangeInsertPoint_Click(object sender, EventArgs e)
		{
			this.index++;
			if (this.index == 5)
			{
				this.index = 0;
			}
			this.m_MainPreviewer.Refresh();
			this.PressEsc();
		}

		private void LengthcomboBox_TextChanged(object sender, EventArgs e)
		{
			this.m_OldData.dLength = this.LengthcomboBox.Text;
		}

		private void WidthcomboBox_TextChanged(object sender, EventArgs e)
		{
			this.m_OldData.dWidth = this.WidthcomboBox.Text;
		}

		private void HeightcomboBox_TextChanged(object sender, EventArgs e)
		{
			this.m_OldData.dHeight = this.HeightcomboBox.Text;
		}

		private void ChangeViewByData()
		{
			double num = 1.0;
			double num2 = 1.0;
			Line line = null;
			Line line2 = null;
			if (this.LengthcomboBox.Text == null || this.WidthcomboBox.Text == null)
			{
				return;
			}
			this.m_OldData.dLength = this.LengthcomboBox.Text;
			this.m_OldData.dWidth = this.WidthcomboBox.Text;
			if (this.arLandPoints.Count != 0)
			{
				line = Line.CreateBound(this.arLandPoints[0], this.arLandPoints[1]);
				line2 = Line.CreateBound(this.arLandPoints[1], this.arLandPoints[2]);
			}
			double num3 = line.Length;
			double num4 = line2.Length;
			XYZ item = this.arLandPoints[0];
			this.arLandPoints.Clear();
			if (this.m_OldData.dLength != "" && this.strlength != "" && this.m_OldData.dLength != this.strlength)
			{
				num = double.Parse(this.m_OldData.dLength) / double.Parse(this.strlength);
			}
			if (this.m_OldData.dWidth != "" && this.strlength != "" && this.m_OldData.dWidth != this.strwidth)
			{
				num2 = double.Parse(this.m_OldData.dWidth) / double.Parse(this.strwidth);
			}
			if (num != 1.0 || num2 != 1.0)
			{
				this.m_bDataIsChange = true;
			}
			this.strlength = this.LengthcomboBox.Text;
			this.strwidth = this.WidthcomboBox.Text;
			num4 *= num;
			num3 *= num2;
			this.arLandPoints.Add(item);
			this.arLandPoints.Add(new XYZ(2.0, num3, 0.0));
			this.arLandPoints.Add(new XYZ(2.0 + num4, 2.0, 0.0));
			this.arLandPoints.Add(new XYZ(2.0 + num4, 2.0 + num3, 0.0));
		}

		private void LengthcomboBox_MouseLeave(object sender, EventArgs e)
		{
			if (this.LengthcomboBox.Text != null && !Regex.IsMatch(this.LengthcomboBox.Text, "(?i)[^a-z]*[a-z]+[^a-z]*"))
			{
				this.ChangeViewByData();
				this.m_MainPreviewer.Refresh();
			}
		}

		private void WidthcomboBox_MouseLeave(object sender, EventArgs e)
		{
			if (this.LengthcomboBox.Text != null && !Regex.IsMatch(this.LengthcomboBox.Text, "(?i)[^a-z]*[a-z]+[^a-z]*"))
			{
				this.ChangeViewByData();
				this.m_MainPreviewer.Refresh();
			}
		}

		private void OccupiedTabControl_SelectedIndexChanged(object sender, EventArgs e)
		{
			if (this.OccupiedTabControl.SelectedIndex == 0)
			{
				this.m_bIsEndPipeOccupied = false;
				this.m_CurrentOrder = "PipeOccupied";
			}
			else if (this.OccupiedTabControl.SelectedIndex == 1)
			{
				this.m_CurrentOrder = "EquipmentOccupied";
				this.m_bIsEndPipeOccupied = true;
			}
			this.PressEsc();
		}

		private XmlElement FindXmlData()
		{
			string userDirectoryFile = SetPipeInfoForm.GetUserDirectoryFile("\\OccupiedData.xml");
			this.tempPath = userDirectoryFile;
			File.Exists(userDirectoryFile);
			this.xmlDoc = new XmlDocument();
			this.xmlDoc.Load(userDirectoryFile);
			return this.xmlDoc.DocumentElement;
		}

		public static string GetUserDirectoryFile(string strDataFileName)
		{
			try
			{
				string text = Product.UserDataLocation + strDataFileName;
				if (!new FileInfo(text).Exists)
				{
					new FileInfo(Product.DataLocation + strDataFileName).CopyTo(text);
				}
				return text;
			}
			catch
			{
				YJKMessageBox.Show("初始化用户数据文件(" + strDataFileName + ")失败。");
			}
			return "";
		}

		private List<string> GetTypeXmlValue()
		{
			XmlElement xmlElement = this.FindXmlData();
			List<string> result = new List<string>();
			string empty = string.Empty;
			if (xmlElement == null)
			{
				return null;
			}
			foreach (object obj in xmlElement.ChildNodes)
			{
				XmlNode xmlNode = (XmlNode)obj;
				if (xmlNode.Name == "PipeOccupied")
				{
					IEnumerator enumerator2 = xmlNode.ChildNodes.GetEnumerator();
					{
						while (enumerator2.MoveNext())
						{
							object obj2 = enumerator2.Current;
							if (obj2 is XmlElement)
							{
								this.InitEachComboBox(obj2 as XmlElement);
							}
						}
						continue;
					}
				}
				if (xmlNode.Name == "EquipmentOccupied")
				{
					foreach (object obj3 in xmlNode.ChildNodes)
					{
						if (obj3 is XmlElement)
						{
							this.InitEachComboBox(obj3 as XmlElement);
						}
					}
				}
			}
			return result;
		}

		private void InitEachComboBox(XmlElement inputxml)
		{
			List<string> list = new List<string>();
			if (inputxml.Name == "comboBox3")
			{
				list = this.Substr(inputxml.GetAttribute("value"));
				if (list.Count == 0)
				{
					list.Add("300");
				}
				foreach (string item in list)
				{
					this.comboBox3.Items.Add(item);
					this.dicComboBoxText[inputxml.Name].Add(item);
				}
				this.comboBox3.SelectedIndex = 0;
				return;
			}
			if (inputxml.Name == "comboBox4")
			{
				list = this.Substr(inputxml.GetAttribute("value"));
				if (list.Count == 0)
				{
					list.Add("300");
				}
				foreach (string item2 in list)
				{
					this.comboBox4.Items.Add(item2);
					this.dicComboBoxText[inputxml.Name].Add(item2);
				}
				this.comboBox4.SelectedIndex = 0;
				return;
			}
			if (inputxml.Name == "comboBox5")
			{
				list = this.Substr(inputxml.GetAttribute("value"));
				if (list.Count == 0)
				{
					list.Add("2000");
				}
				foreach (string item3 in list)
				{
					this.comboBox5.Items.Add(item3);
					this.dicComboBoxText[inputxml.Name].Add(item3);
				}
				this.comboBox5.SelectedIndex = 0;
				return;
			}
			if (inputxml.Name == "LengthcomboBox")
			{
				list = this.Substr(inputxml.GetAttribute("value"));
				if (list.Count == 0)
				{
					list.Add("3000");
				}
				foreach (string item4 in list)
				{
					this.LengthcomboBox.Items.Add(item4);
					this.dicComboBoxText[inputxml.Name].Add(item4);
				}
				this.LengthcomboBox.SelectedIndex = 0;
				return;
			}
			if (inputxml.Name == "WidthcomboBox")
			{
				list = this.Substr(inputxml.GetAttribute("value"));
				if (list.Count == 0)
				{
					list.Add("2000");
				}
				foreach (string item5 in list)
				{
					this.WidthcomboBox.Items.Add(item5);
					this.dicComboBoxText[inputxml.Name].Add(item5);
				}
				this.WidthcomboBox.SelectedIndex = 0;
				return;
			}
			if (inputxml.Name == "HeightcomboBox")
			{
				list = this.Substr(inputxml.GetAttribute("value"));
				if (list.Count == 0)
				{
					list.Add("2000");
				}
				foreach (string item6 in list)
				{
					this.HeightcomboBox.Items.Add(item6);
					this.dicComboBoxText[inputxml.Name].Add(item6);
				}
				this.HeightcomboBox.SelectedIndex = 0;
			}
		}

		private List<string> Substr(string inputstr)
		{
			List<string> list = new List<string>();
			while (!(inputstr == ","))
			{
				int num = inputstr.IndexOf(",");
				if (num == -1)
				{
					break;
				}
				list.Add(inputstr.Substring(0, num));
				inputstr = inputstr.Substring(num).Remove(0, 1);
			}
			return list;
		}

		private void CloseBtn_Click(object sender, EventArgs e)
		{
			base.Close();
		}

		private bool bExist;

		private bool bChange;

		public string m_CurrentOrder = "PipeOccupied";

		public XYZ m_TransVector;

		public List<CurveInfo> curveInfoList = new List<CurveInfo>();

		public ControlData m_OldData;

		private Previewer m_MainPreviewer;

		private List<XYZ> arLandPoints = new List<XYZ>();

		private List<XYZ> lstInsertPt = new List<XYZ>();

		private string strlength = "3000";

		private string strwidth = "2000";

		private Transform m_Transform;

		public int index;

		protected const PenColor m_BasePointColor = PenColor.PC_Red;

		protected const DashStyle m_Solid = DashStyle.Solid;

		private Dictionary<string, List<string>> dicComboBoxText = new Dictionary<string, List<string>>();

		private List<XYZ> lstOldxyz = new List<XYZ>();

		private bool m_bDataIsChange;

		private bool m_bifBackGroundEsc;

		private bool m_bIsEndPipeOccupied;

		private string tempPath;

		private static string typeXmlName = "\\OccupiedData.xml";

		public int nowFamilyFileIndex = -1;

		public int EquipmentFamilyIndex = -1;

		private XmlDocument xmlDoc;
	}
}
